<?php

namespace App\Http\Controllers\home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ShowData extends Controller
{
    function showData(Request $request)
    {
        $startDate = $request->get("startDate");
        $endData = $request->get("endDate");
        $gameId = $request->get("gameId");
        $nextPage = $request->get("nextPage");
        $maxPage = $request->get("maxPage");
        $categoryId = $request->get("categoryId");

        $data =getComment($startDate,$endData,$gameId,$nextPage,$maxPage,$categoryId);
        $data = json_decode($data);
        foreach ($data->ret->searchDatas as $arr) {
            foreach ($arr as $k => $v) {
                switch ($k) {
                    case "content" : {
                        echo "评论：$v ";
                        break;
                    }
                    case "rank" : {
                        echo "星级：$v ";
                        break;
                    }
                    case "categoryComment": {
                        echo "平台：$v ";
                        break;
                    }
                    case "createtime": {
                        echo "时间：$v ";
                        break;
                    }
                }
            }
            echo "<br>";
        }
    }

    function getData(Request $request){
        $startDate = $request->get("startDate");
        $endData = $request->get("endDate");
        $gameId = $request->get("gameId");
        $nextPage = $request->get("nextPage");
        $maxPage = $request->get("maxPage");
        $categoryId = $request->get("categoryId");

        $data =getComment($startDate,$endData,$gameId,$nextPage,$maxPage,$categoryId);
        return $data;
    }
}
